<?php

namespace app\index\controller;

use app\BaseController;

class Wechat extends BaseController
{
    public function initialize(){
        session("url",request()->url());
        if(!session('wechat_openid')){
            $redirect_uri=$this->getCurrentUrl()."/index/callback/getWechatUser";;
            $url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".env("APP.WECHAT_ACCOUNT_APPID")."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
            header("Location:".$url);
        }
    }

}